// -*- coding: utf-8 -*- 
/**
 * Project: Java8InActionT
 * Creator: yanking
 * Create time: 2022-01-28 14:52
 * IDE: IntelliJ IDEA
 * Introduction:
 */
package com.primeNumberCollector;

import java.util.Scanner;
import java.util.stream.IntStream;

import static java.util.stream.Collectors.partitioningBy;

public class getPrimeNumber {
    public static void main(String[] args) {
        Scanner myScanner = new Scanner(System.in);
        System.out.println("Please input a candidate!");
        int n = myScanner.nextInt();
        System.out.println(IntStream.rangeClosed(2, n).boxed().collect(
                partitioningBy(getPrimeNumber::isPrime)));
        // System.out.println(IntStream.rangeClosed(2, n).boxed().collect(new primeNumberCollector()));
    }

    public static boolean isPrime(int candidate) {
        return IntStream.rangeClosed(2, (int) Math.sqrt(candidate)).noneMatch(
                i -> candidate % i == 0);
    }
}
